package com.jiepos.mpos.biz.channel.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.channel.service.InfChannelService;
import com.jiepos.mpos.common.entity.App_Inf_ChannelEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 * 
 * 
 * <p>标题: —— 通道信息表控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.biz.channel.controller 
 * @author 张学涛
 * @version 1.0
 * @since 2017年9月21日下午7:31:41
 * @history（历次修订内容、修订人、修订时间等）
 */
@Controller
@RequestMapping("channelinf")
public class InfChannelController extends BaseController {
	
	@Autowired
	private InfChannelService infChannelService;
	
	/**
	 * 进入通道信息列表页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getChannelInfList.do")
	public ModelAndView getChannelInfList(HttpServletRequest request,HttpServletResponse response,Pagination pagination){
		ModelAndView model=new ModelAndView("/module/channel/channelinf/channelinf_list");
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 查询通道列表信息json数据
	 * @param pagination
	 * @param infChannel
	 * @return
	 */
	@RequestMapping("/getChannelInfListJson.do")
	public @ResponseBody Map getChannelInfListJson(Pagination pagination,App_Inf_ChannelEntity infChannel){
		return infChannelService.getChannelInfList(pagination, infChannel);
	}
	
	/**
	 * 进入通道信息详细页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @param channel_uuid
	 * @return
	 */
	@RequestMapping("/getChannelInfDetail.do")
	public ModelAndView getChannelInfDetail(HttpServletRequest request,HttpServletResponse response,Pagination pagination,
			String channel_uuid){
		ModelAndView model=new ModelAndView("/module/channel/channelinf/channelinf_detail");
		App_Inf_ChannelEntity infChannel=infChannelService.getChannelInfById(channel_uuid);
		model.addObject("infChannel", infChannel);
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 保存通道信息
	 * @param request
	 * @param response
	 * @param infChannel
	 * @return
	 */
	@RequestMapping("/saveChannelInf.do")
	public ModelAndView saveChannelInf(HttpServletRequest request,HttpServletResponse response,App_Inf_ChannelEntity infChannel){
		infChannelService.saveChannelInf(infChannel, super.getLoginUser(request, response));
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getChannelInfList.do"), map);
	}
	
	/**
	 * 删除通道信息
	 * @param request
	 * @param response
	 * @param channel_uuids
	 * @return
	 */
	@RequestMapping("/deleteChannelInfByIds.do")
	public ModelAndView deleteChannelInfByIds(HttpServletRequest request,HttpServletResponse response,String channel_uuids){
		infChannelService.deleteChannelInfByIds(channel_uuids);
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getChannelInfList.do"), map);
	}
	
	
	/**
	 * 校验通道信息
	 * @param infChannelGrpEntity
	 * @return
	 */
	@RequestMapping("/checkChannelInf.do")
	public @ResponseBody String checkChannelInf(App_Inf_ChannelEntity infChannel){		
		return infChannelService.checkChannelInf(infChannel);
	}
	
	/**
	 * 根据通道类型获取通道
	 * @param chn_tp
	 * @return
	 */
	@RequestMapping("/getChannelByTp.do")
	@ResponseBody
	public List<Map<String, Object>> getChannelByTp(String chn_tp){
		return infChannelService.getChannelByTp(chn_tp);
	}

}
